import {Component, OnInit} from '@angular/core';
import {Router} from '@angular/router';
import {FormGroup, FormBuilder, Validators} from '@angular/forms';
import {login_background_image, login_title} from '../../config/config';


@Component({
  selector: 'app-login',
  styleUrls: ['login.component.css'],
  templateUrl: 'login.component.html'
})
export class LoginComponent implements OnInit {


  backgroundImage: string = login_background_image;
  loginTitle: string = login_title;

  validateForm: FormGroup;
  userName: string;
  password: string;

  _logining = false;

  constructor(private fb: FormBuilder,private router:Router) {
  }

  ngOnInit() {
    this.validateForm = this.fb.group({
      userName: [this.userName, [Validators.required]],
      password: [this.password, [Validators.required]],
    });

  }

  submitForm() {
    for (const i in this.validateForm.controls) {
      this.validateForm.controls[i].markAsDirty();
      this.validateForm.controls[i].updateValueAndValidity();
    }

    this.router.navigateByUrl('/sys/welcome');
  }
}
